package com.xh.controller.data;

import com.xh.service.CommentService;
import com.xh.vo.Comment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;


@Controller
public class CommentController {
    @Resource
    private CommentService commentService;
    @PostMapping("/InsertComment")
    public String InsertComment(@RequestParam("userId") String userId,
                                @RequestParam("bId") String bId,
                                @RequestParam("comment") String comment){
        int userID = Integer.parseInt(userId);
        int bID = Integer.parseInt(bId);
        Comment comment1 = new Comment(userID, bID, comment);
        commentService.insertComment(comment1);
        return "redirect:/toBlogContent/"+comment1.getBid()+"/"+comment1.getUserId();  //  /toBlogContent/{Bid}/{userId}
    }
}
